﻿package src.cenfun{
	import flash.display.*;
	import flash.geom.*;
	import flash.events.*;
	import flash.filters.*;
	import src.cenfun.*;
	public class Ball extends Sprite {
		private var tw:Number;
		private var th:Number;
		private var myball:Sprite = new Sprite();
		private var ball:Shape = new Shape();
		public function Ball(tx:Number, ty:Number, tr:Number, tc:Number) {
			var type:String = GradientType.RADIAL;
			var colors:Array = [tc, tc];
			var alphas:Array = [.3, 1];
			var ratios:Array = [0, 255];
			var spreadMethod:String = SpreadMethod.PAD;
			var interp:String = InterpolationMethod.LINEAR_RGB;
			var focalPtRatio:Number = 0;
			var matrix:Matrix = new Matrix();
			matrix.createGradientBox(2*tr, 2*tr, 0, 0, 0);
			ball.graphics.beginGradientFill(type, colors,alphas,ratios, matrix, spreadMethod, interp, focalPtRatio);
			ball.graphics.drawCircle(tr, tr, tr);
			ball.graphics.endFill();
			myball.addChild(ball);
			//
			myball.graphics.beginFill(0xffffff, 1);
			myball.graphics.drawCircle(tr, tr, tr);
			myball.graphics.endFill();
			myball.filters = getShadow(0x000000, .5);
			myball.x = tx;
			myball.y = ty-tr;
			addChild(myball);
		}
		private function getShadow(c:Number,a:Number):Array {
			return new Array(new DropShadowFilter(1,45,c,a,4,4,1,1));
		}
		public function setSize(w:Number, h:Number):void {
			tw = w;
			th = h;
		}

	}
}